package com.example.sample.activity;

import com.example.app.BaseActivity;
import com.example.sample.R;

import android.app.Activity;
import android.graphics.Bitmap;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.os.Handler;
import android.util.Log;

import net.liteheaven.xblib.widget.imageview.RoundImageView;

public class RoundImageViewActivity extends BaseActivity {
	
	private static final String TAG = "RoundImageViewActivity";
	private RoundImageView mRiv;
	private Handler mHandler = new Handler();
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_round_imageview);
		mRiv = (RoundImageView)findViewById(R.id.roundImageView);

		mHandler.postDelayed(new Runnable() {
			
			@Override
			public void run() {
				Drawable drawable = getResources().getDrawable(R.drawable.bk);
				final Bitmap bm = ((BitmapDrawable) drawable).getBitmap();
				if (bm == null){
					Log.e(TAG, "bm is null");
				}
				if (bm.isRecycled()){
					Log.e(TAG, "bm is isRecycled");
				}
				//mRiv.setImageBitmap(bm);
				mHandler.postDelayed(new Runnable() {
					
					@Override
					public void run() {
						mRiv.setImageBitmap(bm);
					}
				}, 100);
			}
		}, 500);
	}
	
}
